#include "key.h"


uint8_t Key_Read(void)
{
    uint8_t key_num=0;
    if(GPIOPinRead(FButton_PORT_BASE_1,FButton_Up)==0)key_num=1;
    if(GPIOPinRead(FButton_PORT_BASE_2,FButton_Middle)==0)key_num=2;
    if(GPIOPinRead(FButton_PORT_BASE_2,FButton_Down)==0)key_num=3;
    if(GPIOPinRead(FButton_PORT_BASE_2,FButton_Left)==0)key_num=4;
    if(GPIOPinRead(FButton_PORT_BASE_2,FButton_Right)==0)key_num=5;
    return key_num;
}

void Key_EmShak(keyParameter *keyStatus)
{
    uint8_t Key_Val;
    Key_Val=Key_Read();
    keyStatus->down=Key_Val&(keyStatus->old^Key_Val);
    keyStatus->up=~Key_Val&(keyStatus->old^Key_Val);
    keyStatus->old=Key_Val;
}

